<@pp.dropOutputFile/>
<#include "../common/util.ftl">
<#-- iterate table list-->
<#list doc.tables as table>

<#-- generate package name -->
<#assign app = doc.artifactid?replace(".", "/")>
<#assign package = table.moduleid?replace(".", "/")>
<#assign fileName = table.name?cap_first>
<@pp.changeOutputFile name = "/" + package  + "/View/" + fileName + "Page.vb"/>
<#assign package = table.moduleid?replace("/", ".")>
Imports Stone
Imports Neutron_core.jsr.data.system_parameter

Public Class ${fileName}Page
    Implements IPreferencePage
	<#list table.fields as field>
	Private Shared ${field.name?upper_case}_ID = ""
	</#list>
	
    Public Function GetParameters() As Dictionary(Of String, scalar.Scalar) Implements IPreferencePage.GetParameters
        Dim res = New Dictionary(Of String, scalar.Scalar)
        <#list table.fields as field>
		<#if isText(field.type)>
		res.Add(${field.name?upper_case}_ID, New scalar.Scalar(${field.name?upper_case}_ID, TextBoxX_${field.name?cap_first}.Text))
		</#if>
		<#if isInteger(field.type)>
		res.Add(${field.name?upper_case}_ID, New scalar.Scalar(${field.name?upper_case}_ID, IntegerInput_${field.name?cap_first}.Text))
		</#if>
		<#if isReal(field.type)>
		res.Add(${field.name?upper_case}_ID, New scalar.Scalar(${field.name?upper_case}_ID, DoubleInput_${field.name?cap_first}.Text))
		</#if>
		<#if isDate(field.type)>
		res.Add(${field.name?upper_case}_ID, New scalar.Scalar(${field.name?upper_case}_ID, DateTimeInput_${field.name?cap_first}.Text))
		</#if>
		</#list>
        Return res
    End Function

    Public Function IsValid() As Boolean Implements IPreferencePage.IsValid
        Return True
    End Function

    Public Sub LoadDefault()
        Dim sp = NeutronParameters.GetInstance()
       <#list table.fields as field>
		<#if isText(field.type)>
		TextBoxX_${field.name?cap_first}.Text = sp.GetDefault(${field.name?upper_case}_ID)
		</#if>
		<#if isInteger(field.type)>
		IntegerInput_${field.name?cap_first}.Text = sp.GetDefault(${field.name?upper_case}_ID)
		</#if>
		<#if isReal(field.type)>
		DoubleInput_${field.name?cap_first}.Text = sp.GetDefault(${field.name?upper_case}_ID)
		</#if>
		<#if isDate(field.type)>
		DateTimeInput_${field.name?cap_first}.Text = sp.GetDefault(${field.name?upper_case}_ID)
		</#if>
	</#list>
    End Sub

    Public Sub LoadParameters(data As Dictionary(Of String, scalar.Scalar)) Implements IPreferencePage.LoadParameters
        Try
			Dim m As Map = New Map(data)
		<#list table.fields as field>
			<#if isText(field.type)>
			TextBoxX_${field.name?cap_first}.Text = m.GetValue(${field.name?upper_case}_ID, "")
			</#if>
			<#if isInteger(field.type)>
			IntegerInput_${field.name?cap_first}.Text = m.GetValue(${field.name?upper_case}_ID, "")
			</#if>
			<#if isReal(field.type)>
			DoubleInput_${field.name?cap_first}.Text = m.GetValue(${field.name?upper_case}_ID, "")
			</#if>
			<#if isDate(field.type)>
			DateTimeInput_${field.name?cap_first}.Text = m.GetValue(${field.name?upper_case}_ID, "")
			</#if>
		</#list>
        Catch ex As Exception
            Debug.WriteLine(ex.Message)
        End Try
    End Sub

    Private Sub ButtonX_More_Click(sender As System.Object, e As System.EventArgs) Handles ButtonX_More.Click

    End Sub

    Private Sub ButtonX_Default_Click(sender As System.Object, e As System.EventArgs) Handles ButtonX_Default.Click
        LoadDefault()
    End Sub
	
End Class
</#list>